package com.springboot.boot02.controller;

import com.springboot.boot02.bean.Emp;
import com.springboot.boot02.bean.ResultCode;
import com.springboot.boot02.service.EmpService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import java.util.List;

@RestController
@RequestMapping("/emp")
public class EmpController {
    @Resource
    private EmpService empService;

    @GetMapping("/find")
    public ResultCode<List<Emp>> find(){
        List<Emp> list=empService.list();
        return new ResultCode<List<Emp>>("200",null,list);
    }

    @PostMapping("/save")
    public void save(Emp emp){
        empService.saveOrUpdate(emp);
    }

    @PutMapping("/update")
    public void update(Emp emp){
        empService.saveOrUpdate(emp);
    }

    @DeleteMapping("/remove")
    public void remove(int id){
        empService.removeById(id);
    }
}
